package com.DAOs;  
  
import com.entities.Person;
import java.util.List;  
  
import org.hibernate.Criteria;  
import org.hibernate.SessionFactory;  
import org.springframework.beans.factory.annotation.Autowired;  
import org.springframework.stereotype.Repository;  
import org.springframework.transaction.annotation.Transactional;  
  

@Repository  
@Transactional  
public class PersonsDAO  
{  
 @Autowired  
 private SessionFactory sessionFactory;  
   
 public Person getById(int id)  {  
    return (Person) sessionFactory.getCurrentSession().get(Person.class, id);  
 }  
   
   
 @SuppressWarnings("unchecked")  
 public List<Person> getAllContacts()  {  
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Person.class);   
    return criteria.list();  
 }  
   

  
}  
